package com.sunny.ynhz.ui;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import com.sunny.ynhz.api.NetUrl;
import com.sunny.ynhz.ui.base.CommentBaseWebActivity;
import com.sunny.ynhz.utils.CommentUtils;
import com.sunny.ynhz.utils.SPUtil;
import com.sunny.ynhz.utils.ToastUtils;
public class NewsDetailActivity extends CommentBaseWebActivity {
    private String id;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ll_option.setVisibility(View.VISIBLE);
        ll_send.setVisibility(View.GONE);
        ll_option.setOnClickListener(view -> {
            ll_option.setVisibility(View.GONE);
            ll_send.setVisibility(View.VISIBLE);
            showSoftInputFromWindow(NewsDetailActivity.this, ed_comment);
        });
        ed_comment.setOnFocusChangeListener((view, b) -> {
            if (!b) {
                ll_option.setVisibility(View.VISIBLE);
                ll_send.setVisibility(View.GONE);
            }
        });
        CommentUtils.getStarNum(id, this);

    }

    @Override
    public void loadUrl(String url) {
        id = getIntent().getStringExtra("id");
        url = NetUrl.baseUrl + "pages/patrol_problem/newsInformationRead.html?id=" + id + "&status=0" + "&pagetitle=1&userId=" + SPUtil.get("userId", "").toString();
        super.loadUrl(url);
    }

    @Override
    public void ensure() {
        if (TextUtils.isEmpty(ed_comment.getText().toString())) {
            ToastUtils.SingleToastUtil(this, "请输入提交内容");
            return;
        }
        closeSoftInputFromWidow(this, ed_comment);
        CommentUtils.updateComment(id, SPUtil.get("userId", "").toString(), "3", ed_comment.getText().toString(), this);
    }

    @Override
    public void toStar() {
        super.toStar();
        CommentUtils.toStar(id, this);
    }

    @Override
    public void setWebTitle(String title) {
        title=getIntent().getStringExtra("title");
        super.setWebTitle(title);
    }
}
